package com.supercube.sport.yoga.controller;

import com.supercube.sport.yoga.bo.MemberGoodsBo;
import com.supercube.sport.yoga.domain.GoodsStock;
import com.supercube.sport.yoga.service.GoodsStockService;
import com.supercube.sport.yoga.utils.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description：
 * Created By guowen
 */
@RestController
@RequestMapping("/reportForms")
@Api(tags = "商品表")
@Slf4j
public class GoodsStockController {
    @Autowired
    private GoodsStockService goodsStockService;

    @ApiOperation(value = "新增商品", notes = "新增商品")
    @PostMapping("/saveGoods")
    public ResultInfo saveGoods (@RequestBody GoodsStock dto) {
        goodsStockService.saveGoods(dto);
        return ResultInfo.success("保存成功");
    }

    @ApiOperation(value = "修改商品", notes = "修改商品")
    @PostMapping("/editGoods")
    public ResultInfo editGoods (@RequestBody GoodsStock dto) {
        goodsStockService.editGoods(dto);
        return ResultInfo.success("修改成功");
    }


    @ApiOperation(value = "会员购买商品", notes = "会员购买商品")
    @PostMapping("/memberByGoods")
    public ResultInfo memberByGoods (@RequestBody MemberGoodsBo bo) {
        goodsStockService.memberByGoods(bo);
        return ResultInfo.success("保存成功");
    }
}
